package com.lk.oauth2.sso.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import com.lk.base.result.Result;

/**
 * @program: lk-cloud-oauth2-parent
 * @description:
 * @author: Aspirin
 * @create: 2020-09-17 21:59
 */
@Controller
public class MainController {
  private static Logger logger = LoggerFactory.getLogger(MainController.class);

  @GetMapping("/")
  public String index() {
    return "index";
  }

  @Autowired private OAuth2RestTemplate oAuth2RestTemplate;

  @GetMapping("/member")
  public String member() {
    Result result =
        oAuth2RestTemplate.getForObject("http://localhost:7001/product/list", Result.class);
    logger.info("获取的商品信息：{}", result.toString());
    return "member";
  }
}
